/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.softserve.fproject.dispatcher.model;

import com.softserve.fproject.services.*;
import com.softserve.fproject.services.FlightServiceStub.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.*;

/**
 *
 * @author Den
 */
public class FlightManager {

    public static List<Flight> getAllFlights() {
        try {
            FlightServiceStub stub = new FlightServiceStub();
            // "http://localhost:8080/fproject/services/FlightService");

            FlightServiceStub.GetAllFlights gaf = new FlightServiceStub.GetAllFlights();
            FlightServiceStub.GetAllFlightsE gafe = new FlightServiceStub.GetAllFlightsE();
            gafe.setGetAllFlights(gaf);

            GetAllFlightsResponseE resp = stub.getAllFlights(gafe);
            Flight[] res = resp.getGetAllFlightsResponse().get_return();
            return Arrays.asList(res);
        } catch (Exception ex) {
            Logger.getLogger(FlightManager.class.getName()).log(Level.SEVERE, null, ex);
        }
        return new ArrayList<Flight>();
    }
}
